﻿using Circus.Utility.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WoAiPao {

    /// <summary>
    /// 提供页面相关接口。
    /// </summary>
    public class PageController {

        /// <summary>
        /// 获取所有苹果产品类型。
        /// </summary>
        /// <returns></returns>
        public static List<AppleProduct> getAllProducts() {
            return new List<AppleProduct>() {
                AppleProduct.iphone,
                AppleProduct.ipad,
            };
        }

        /// <summary>
        /// 获取指定产品类型的所有型号。
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public static List<string> getAllProductType(AppleProduct product) {
            return new List<string>() {
               "Iphone 5C",
                "Iphone 6",
            };
        }

        /// <summary>
        /// 获取指定产品类型的所有型号。
        /// </summary>
        /// <param name="productType"></param>
        /// <returns></returns>
        public static List<dynamic> getChoices(string productType) {
            return new List<dynamic>() {
                 new {
                     name = "剩余保修期",
                     type = "radio",
                     items = new JsonArray() {
                         "无",
                         "3个月以上",
                         "6个月以上",
                     },
                 },
                 new {
                     name = "剩余保修期",
                     type = "checkbox",
                     items = new JsonArray() {
                         "无",
                         "3个月以上",
                         "6个月以上",
                     },
                 },
                 new {
                     name = "剩余保修期",
                     type = "text",
                 }
            };
        }

        /// <summary>
        /// 提交回购订单。
        /// </summary>
        /// <param name="productType"></param>
        /// <param name="choices">用户的选择情况。如 {"剩余保修期":"3个月以上"}。如果不传此参数，返回 全新手机报价。</param>
        /// <returns>如果无法评估返回 -1。</returns>
        public static int getPrice(string productType, string choices = null) {
            return 1000;
        }

        /// <summary>
        /// 提交回购订单。
        /// </summary>
        /// <param name="productType"></param>
        /// <param name="choices">用户的选择情况。如 {"剩余保修期":"3个月以上"}</param>
        /// <param name="cells"></param>
        /// <returns>返回 {status: 0, msg: "保存成功"}</returns>
        public static dynamic saveOrderForRecycle(string productType, string choices, string cells) {
            return new {
                status = 0,
                orderId = 1000, // 订单号
                msg = "保存成功"
            };
        }

        /// <summary>
        /// 提交置换订单。
        /// </summary>
        /// <param name="productType"></param>
        /// <param name="choices">用户的选择情况。如 {"剩余保修期":"3个月以上"}</param>
        /// <param name="cells"></param>
        /// <returns>返回 {status: 0, msg: "保存成功"}</returns>
        public static dynamic saveOrderForExchange(string productType, string choices, string cells) {
            return new {
                status = 0,
                orderId = 1000, // 订单号
                msg = "保存成功"
            };
        }

    }

}